<?php

class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */

        $this->request = $this->getRequest();
        $this->param = $this->request->getParams();
        


    }

    public function indexAction()
    {
        // action body
        $session = new Zend_Session_Namespace('Zend_Auth');

        //if (Zend_Auth::getInstance()->hasIdentity() && isset($session->data)) {
        if (!isset($session->data)) {
           $param = array(
               'action' => 'login',
                'controller' => 'index'
           );
           $this->_redirect($this->view->url($param, 'default', true));
        }

        $param = array(
               'action' => 'index',
               'controller' => 'member'
           );
           $this->_redirect($this->view->url($param, 'default', true));


        $this->view->msg = (isset($this->param['msg'])) ? $this->param['msg'] : "";
    }
    
    public function loginAction(){
        $this->request = $this->getRequest();
        $this->param = $this->request->getParams();
        
        $this->view->msg = (isset($this->param['msg'])) ? $this->param['msg'] : "";

        
    }

    public function adminAction()
    {
        // action body

        $sess = new Zend_Session_Namespace('Zend_Auth_Admin');

        //if (Zend_Auth::getInstance()->hasIdentity() && isset(Zend_Auth::getInstance()->getIdentity()->username)) {
        if (isset($sess->data)){
           $param = array(
               'action' => 'index',
               'controller' => 'admin'
           );
           $this->_redirect($this->view->url($param, 'default', true));
        }

        $this->request = $this->getRequest();
        $this->param = $this->request->getParams();
        $this->view->msg = (isset($this->param['msg'])) ? $this->param['msg'] : "";
        
    }


}

